
#include "fxcc/core/graph/opengl3/InputLayout.h"

using namespace fxcc::graph::opengl3;

void VertexAttr::Use() const
{

    if (type == GL_FLOAT)
    {
        glVertexAttribPointer(
            index,
            size,
            type,
            normalized ? GL_TRUE : GL_FALSE,
            stride,
            pointer);
    }
    else if (type == GL_INT || type == GL_UNSIGNED_INT || type == GL_SHORT || type == GL_UNSIGNED_SHORT)
    {
        glVertexAttribIPointer(
            index,
            size,
            type,
            stride,
            pointer);
    }
    glEnableVertexAttribArray(index);
}

void InputLayout::Use() const
{
    for (const auto &it : m_VertexAttrs)
    {
        it.Use();
    }
}